<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title></title>
<link rel="stylesheet" href="static/css/pintuer.css">
<link rel="stylesheet" href="static/css/admin.css">
<script src="static/js/jquery.js"></script>
<script src="static/js/pintuer.js"></script>
<link rel="stylesheet" href="static/layui/css/layui.css"  media="all">
<script src="static/layui/layui.js" charset="utf-8"></script>

</head>
<body >

<form id="subForm" method="post" action="" name="subForm">

		<input type="text" name="pages" value="${current}" style="display:none">
		<div class="panel admin-panel">
			<div class="panel-head">
				<strong class="icon-reorder"> 课程管理</strong>
			</div>
			<%--<form id=" " method="post" action="" name="formSerch1">--%>
				<br>
				<div class="form-group">

					<div class="field">
						课程编号:
						<input type="text" class="input w50" name="number" id="number"/>
						课程名称:
						<input type="text" class="input w50" name="name" id="name"/>
						课程学时:
						<input type="text" class="input w50" name="xueshi" id="xueshi"/>
						<br>
						课程学分:
						<input type="text" class="input w50" name="xuefeng" id="xuefeng"/>
						课程类别:
						<select name="type" class="input w50" id="type">
							<option value=""></option>
							<c:forEach var="type" items="${typeList}">
								<option value="${type.name}">${type.name}</option>
							</c:forEach>
						</select>

						开课学期:
						<select name="xueqi" class="input w50" id="xueqi">
							<option value="">请选择学期</option>
							<option value="1">1</option>
							<option value="2">2</option>
						</select>

						<%--<button onclick="serch2()">查询</button>--%>
						<%--<button class="button bg-main " onclick="serch2()">
							查询</button>--%>
						<input type="button" onclick="serch2()" value="查询" class="button bg-main  "style="background-color: #09F">
						<div class="tips"></div>
					</div>
				</div>


			<%--</form>--%>


			<div class="padding border-bottom">
				<ul class="search">

					<li style="background-color: #09F"><a href="findAllType.do" class="button "></span> 添加课程</a>
					</li>

					<%--<li style="background-color: #09F"><a href="javascript:void(0);" class="button" onclick="DelSelect()"></span> 批量删除</a>
					</li>--%>

				</ul>

			</div>
			<table class="table table-hover text-center" >
				<tr>
<%--					<th width="100"><input type="checkbox" name="" id="allSelect" class="allSelect" value="">全选</th>--%>
					<th width="120">课程编号</th>
					<th>课程名称</th>
					<th>学时</th>
					<th>学分</th>
					<th>课程类别</th>
					<th>开课学期</th>
					<th>操作</th>



				</tr>
				<c:forEach items="${courseList}" var="zd">
					<tr>
<%--						<td><input  name="ids[]" type="checkbox" value="${zd.id}" >--%>
						<td>${zd.number}</td>
						<td>${zd.name}</td>
						<td>${zd.xueshi}</td>
						<td>${zd.xuefeng}</td>
						<td>${zd.type}</td>
						<td>${zd.xueqi}</td>

						<td>
							<div class="button-group">
								<button><a class="button" style="border-color: #09F" href="courseLook.do?id=${zd.id}">查看信息</a></button>
								<button><a class="button" style="border-color: #09F;" href="courseDel.do?id=${zd.id}&page=${current}" onclick="del()"> 删除课程</a></button>

								<button><a class="button" style="border-color: #09F;" href="courseEdit.do?id=${zd.id}" >修改信息</a></button>

								</div>
						</td>
					</tr>
				</c:forEach>
				<tr>
					<td colspan="8">
						<div class="pagelist">
							<a href="coursePage.do?p=1">首页</a>
							<%--判断是否有上一页--%>
							<c:if test="${current>1}">
								<a style="background-color: gray" href="coursePage.do?p=${current-1}">上一页</a>
							</c:if>

							<c:forEach begin="${(current-3)>1?(current-3):1}"
								end="${(current+3)<total?(current+3):total}" var="k">
								<c:if test="${current==k}">
									<span class="current">${k}</span>
								</c:if>
								<c:if test="${current!=k}">
									<a href="coursePage.do?p=${k}">${k}</a>
								</c:if>

							</c:forEach>

							<%--判断是否有下一页--%>
							<c:if test="${current<total}">
								<a href="coursePage.do?p=${current+1}">下一页</a>
							</c:if>
							<a href="coursePage.do?p=${total}">尾页</a>

						</div>
					</td>
				</tr>
			</table>
		</div>
	</form>
	<script type="text/javascript">

			function serch2(){
			var type=$("#type option:selected").val();
			var xueqi=$("#xueqi option:selected").val();
			var number=$("#number").val();
			var name=$("#name").val();
			var xuefeng=$("#xuefeng").val();
			var xueshi=$("#xueshi").val();
			// alert(type+"xueqi"+xueqi+","+"number:"+number+"name"+name+"xuefeng"+xuefeng+"xueshi"+xueshi)


			window.location.href="courseSerch.do?number="+number+"&name="+name+"&xuefeng="+xuefeng+"&xueshi="+xueshi+"&type="+type+"&xueqi="+xueqi;
		}


		//查询
		function serch1(){


			var xueyuan=$("#sel option:selected").val();
			var id=$("#id").val();
			var name=$("#name").val();
			alert(id+name+xueyuan);
			$.ajax({
				url: "GradeSerch.do", //提价的路径
				type: "post",       //提交方式
				data: {
					"id":id,
					"name":name,
					"college":xueyuan
				},
				dataType: "text",       //规定请求成功后返回的数据
				success: function (data) {
					alert(data);
					//请求成功之后进入该方法，data为成功后返回的数据
				},
				error: function (errorMsg) {
					//请求失败之后进入该方法，errorMsg为失败后返回的错误信息
				}
			});


		}

		//单个删除
		function del(id,mid,iscid){
			if(confirm("您确定要删除吗?")){

			}
		}
		//全选
		$("#allSelect").click(function(){
			$("input[name='ids[]']").each(function(){
				if (this.checked) {
					this.checked = false;
				}
				else {
					this.checked = true;
				}
			});
		})

		//批量删除
		function DelSelect(){
			var Checkbox=false;
			$("input[name='ids[]']").each(function(){
				if (this.checked==true) {
					Checkbox=true;
				}
			});
			if (Checkbox){
				var t=confirm("您确认要删除选中的内容吗？");
				if (t==false) {return false};
				$("#subForm").submit();
				var form = document.forms['subForm'];
				//在这里手工指定提交给哪个ACTION
				form.action = 'courseDelSel.do';
				//执行SUBMIT
				form.submit();
			}
			else{
				alert("请选择您要删除的内容!");
				return false;
			}
		}




		

	</script>
</body>
</html>

